/*-------------------------------------------------
 *
 * OrbitsWriter - An Offline Blog Writer
 *
 * Copyright (C) 2016  devbean@galaxyworld.org
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *-------------------------------------------------*/

#ifndef SOURCEEDITOR_P_H
#define SOURCEEDITOR_P_H

#include "core/core_commons.h"

#include <QPaintEvent>
#include <QWidget>

class QSyntaxHighlighter;

namespace Core
{

class MarkupBuilder;
class MarkupHighlighter;
class SourceEditor;

namespace Internal
{

class LineNumberArea : public QWidget
{
public:
    LineNumberArea(SourceEditor *editor);

    QSize sizeHint() const Q_DECL_OVERRIDE;

protected:
    void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;

private:
    SourceEditor *sourceEditor;
}; // end of class Core::Internal::LineNumberArea

class SourceEditorPrivate : public QObject
{
    Q_OBJECT
    Q_DISABLE_COPY(SourceEditorPrivate)
    DECLARE_PUBLIC(SourceEditor)
public:
    SourceEditorPrivate(SourceEditor *se);
    ~SourceEditorPrivate();

    void lineNumberAreaPaintEvent(QPaintEvent *event);
    int lineNumberAreaWidth();

    void updateLineNumberAreaWidth(int);
    void highlightCurrentLine();
    void updateLineNumberArea(const QRect &rect, int dy);

    void onAppContextAboutToExit();
    void onMainWindowShown();

    MarkupBuilder *builder;
    QSyntaxHighlighter *highlighter;
    QWidget *lineNumberArea;

}; // end of class Core::Internal::SourceEditorPrivate

} // end of namespace Core::Internal

} // end of namespace Core

#endif // SOURCEEDITOR_P_H
